import Vue from 'vue';
import App from './App.vue';
import ElementUI from 'element-ui';
import Viewer from 'v-viewer';
import { bootstrap } from '@/cool/core';

import router from '@/router';
import routes from '@/router/routes/views';
import store from '@/store';
import '@/mock';
import '@/icons/index';
import '@/filter/index';
import '@/assets/css/element-variables.scss';
import 'viewerjs/dist/viewer.css';
import '@/components/common';
Vue.use(Viewer);
Vue.use(ElementUI);

import VueClipboard from 'vue-clipboard2';
Vue.use(VueClipboard);

Vue.config.productionTip = false;
// eslint-disable-next-line
function tableRowClassName({ row, rowIndex }) {
	if (rowIndex % 2 == 0) {
		return 'warning-row';
	} else {
		return 'success-row';
	}
}

const conf = {
	store,
	router,
	['view-routes']: routes,
	['cl-crud']: {
		crud: {
			table: {
				props: {
					stripe: false,
					border: false,
					size: 'medium ',
					'highlight-current-row': true,
					'row-class-name': tableRowClassName
				},
				scopedSlots: {
					// eslint-disable-next-line
					empty: ({ h }) => {
						return (
							<div style="padding:40px 0">
								<icon-svg
									style="width:100px;height:100px"
									name="icon-empty"></icon-svg>
								<div style="line-height:20px;margin-top: -10px;    color: #ccc;">
									暂无数据
								</div>
							</div>
						);
					}
				}
			},
			dict: {
				sort: {
					prop: 'order',
					order: 'sort'
				},

				label: {
					add: '添加',
					delete: '删除',
					update: '修改',
					refresh: '刷新',
					advSearch: '高级搜素'
				}
			},
			fn: {
				permission(that) {
					const { permission } = that.$store.state.menu;
					const { add, delete: del, update } = that.service.permission || {};

					return {
						add: permission.includes(add),
						delete: permission.includes(del),
						update: permission.includes(update)
					};
				}
			},
			event: {
				refresh(data, { app }) {
					app.refresh({
						page: 1,
						app: data
					});
				}
			}
		}
	}
};

bootstrap(conf).then(({ router, store }) => {
	store.dispatch('appLoad');

	new Vue({
		router,
		store,
		render: h => h(App)
	}).$mount('#app');
});
